var wetlandParkId = $("#wetlandParkId").val();
var longitude;
var latitude;
var scale;
var overview = $("a[href='#overviewedit']");
var basicInfo = $("a[href='#basicInfoedit']");
var wetlandType = $("a[href='#wetlandTypeedit']");
var naturaFeature = $("a[href='#naturaFeatureedit']");
var wetlandPlant = $("a[href='#wetlandPlantedit']");
var wetlandAnimal = $("a[href='#wetlandAnimaledit']");
var ecologicalFun = $("a[href='#ecologicalFunedit']");
var socioEconomic = $("a[href='#socioEconomicedit']");
var protectionMainBody = $("a[href='#protectionMainBodyedit']");
var managementOrganization= $("a[href='#managementOrganizationedit']");
var landOwnership = $("a[href='#landOwnershipedit']");
var threatenedStatus = $("a[href='#threatenedStatusedit']");
var multiMedia = $("a[href='#multiMediaedit']");

//信息提交成功后在tab页上显示的提示信息
var successHTML = '<i class="green ace-icon fa fa-check-circle bigger-120"></i>';
//信息有误在tab页上显示的提示信息
var warnHTML = '<i class="red ace-icon fa fa-exclamation-circle bigger-120"></i>';

$(function() {
	getInfos();	
	$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
		// 获取已激活的标签页的名称
		var activeTab = $(e.target).attr("href");
		if(activeTab == "#basicInfoedit"){
			layerInfo();
			gismap();
		}else if(activeTab == "#wetlandTypeedit"){
			typelayerInfo();
			typegismap();
		}else if(activeTab == "#socioEconomicedit"){
			soillayerInfo();
			soilgismap();
		}else if(activeTab == "#protectionMainBodyedit"){
			slayerInfo();
			sgismap();
		}
		// 获取前一个激活的标签页的名称
		//var previousTab = $(e.relatedTarget).text();
		var preHref = $(e.relatedTarget).attr("href");
	
		if(preHref == "#overviewedit"){
			overview_add();
	
		}else if(preHref == "#basicInfoedit"){
			basicInfo_add();
	
		}else if(preHref == "#wetlandTypeedit"){
			wetlandType_add();
	
		}else if(preHref == "#naturaFeatureedit"){
			naturaFeature_add();
	
		}else if(preHref == "#wetlandPlantedit"){
			wetlandPlant_add_sub();
	
		}else if(preHref == "#wetlandAnimaledit"){
			wetlandAnimal_add_sub();
	
		}else if(preHref == "#ecologicalFunedit"){
			ecologicalFun_add();
		
		}else if(preHref == "#socioEconomicedit"){
			socioEconomic_add();
		
		}else if(preHref == "#protectionMainBodyedit"){
			protectionMainBody_add();
		
		}else if(preHref == "#managementOrganizationedit"){
			managementOrganization_add();

		}else if(preHref == "#landOwnershipedit"){
			landOwnership_add();
	
		}else if(preHref == "#threatenedStatusedit"){
			threatenedStatus_add();
		}else if(preHref == "#multiMediaedit"){
			multiMedia_add_sub();
		}
	});
$('#overview_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#basicInfo_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#wetlandType_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#naturaFeature_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#wetlandAnimal_add_sub').click(function() {
		$(document).scrollTop(0);
	});
	$('#wetlandPlant_add_sub').click(function() {
		$(document).scrollTop(0);
	});
	$('#threatenedStatus_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#socioEconomic_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#protectionMainBody_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#managementOrganization_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#landOwnership_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#ecologicalFun_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#multiMedia_btn').click(function() {
		$(document).scrollTop(0);
	});
});

function back() {
	history.back();
}
function getInfos(){
	var id =$("#wetlandParkId").val();
	$.ajax({
		url : "findbyid",
		dataType : "json",
		type : "POST",
		data : {id:id},
		async : false,
		error : function(error) {
			console.log(error.responseText);

			$.gritter.add({
				title : '服务器错误',
				text : '对不起，服务器错误，请联系系统管理员！',
				class_name : 'gritter-error'
			});

		},
		success : function(strValue) {
			if (strValue != null) {
				latitude=strValue.wlin_latitude;
				longitude=strValue.wlin_longitude;
				scale=strValue.wlin_scale;
				//$("#edit_gismapserver").find("option[value='"+strValue.wlin_gis_mapserver+"']").attr("selected",true);
			}
		}
	});
}